Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) Part Number B14308-01 |
Home | Book List | Contents | Index | Master Index | Feedback

# DiscardChanges Method

Applies To

OBinder

Description

This method discards the changes made to the current record.

Usage

oresult DiscardChanges(void)

Remarks

OBound subclass instances allow changes to be made to field values. When those changes are made, the subclass code marks itself as changed with the OBound::Changed method, which in turn marks the current record (of the dynaset that the attached OBinder is managing) as changed with OBinder::Changed.

Sometimes you need to discard changes that have been made. To do this, call DiscardChanges.

After the changes are discarded, all attached bound objects are refreshed with correct values.

Return Value

An oresult indicating whether the operation succeeded (OSUCCESS) or not (OFAILURE).

Example

This example considers handling an OBinder when it is about to be closed.

    // Here's an OBinder that we are using to edit a table
    OBinder tableedit;
    // setup of tableedit goes here (see Workbook for a sample).

    // now the user is closing the window. Deal with any changes.
    if (tableedit.IsChanged())
    { // the current record has a change in it
        // ask the user if they want to save the change
        int yesno = Message("Do you want to save the change?");
        if (yesno == YES_ANSWER)
            tableedit.Update();
        else
            tableedit.DiscardChanges();
    }
    /*

    Now we can close the window.
    By the way, the default behavior when an OBinder is destroyed is for it to
    Update().
    */